import React from 'react';
import classNames from 'classnames';
import exportExcel from '@/utils/exportExcel';
import styles from './index.less';

interface ExportFormProps {
  className?: string;
  count?: number;
  columns: [];
  dataSource: [];
}

const ExportForm: React.FC<ExportFormProps> = (props) => {
  const { className, count, columns = [], dataSource = [] } = props;
  const handleExportExcel = () => {
    exportExcel({
      titleArr: columns,
      itemArr: dataSource,
    });
  };

  return (
    <div className={classNames(styles['export-view'], className)}>
      <div>{count && count !== 0 ? `共找到 ${count} 条内容` : ''}</div>
      <div className={styles['export-box']} onClick={handleExportExcel}>
        导出Excel
      </div>
    </div>
  );
};

export default ExportForm;
